package com.heima.client.article;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.heima.client.article.fallback.ArticleClientFallback;
import com.heima.model.common.dtos.*;
import com.heima.model.common.pojos.article.ApArticle;
import com.heima.model.common.pojos.article.ApArticleConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @author 陈辉
 * @data 2024 15:20
 */
@FeignClient(value = "leadnews-article",fallback = ArticleClientFallback.class)
public interface IArticleClient {

    /**
     * 保存或修改article文章信息
     *
     * @param articleDto
     * @return
     */
    @PostMapping("/api/v1/article/sync")
    public ResponseResult syncArticle(@RequestBody ArticleDto articleDto);


    @PostMapping("api/v1/article/updateomment")
    public ResponseResult updateomment(@RequestBody CommentStatus commentStatus);


    @PostMapping("api/v1/article/articlesele")
    public ResponseResult articlesele(@RequestBody List<Long> entryIds);

    @PostMapping("api/v1/article/getarticle/{userId}/{end}/{begin}")
    public List<ApArticle>getArticle(@PathVariable Integer userId, @PathVariable Date end, @PathVariable Date begin);
    @PostMapping("api/v1/article/getarticle2/{userId}/{end}/{begin}")
    public Page<ApArticle> getArticle2(@PathVariable Integer userId, @PathVariable Date end, @PathVariable Date begin, @RequestBody FindNewsDto findNewsDto);


    @PostMapping("api/v1/article/iscomment/{id}")
    public ApArticleConfig getConfig(@PathVariable Long id);


    /**
     * 修改文章阅读数据
     *
     * @param behaviorDto
     * @return
     */
    @PostMapping("/api/v1/article/updateArticle")
    public ResponseResult updateArticle(@RequestBody ReadBehaviorDto behaviorDto);

    /**
     * 查询article文章信息
     *
     * @param articleDto
     * @return
     */
    @PostMapping("/api/v1/article/loadArticle")
    public ResponseResult loadArticle(@RequestBody ArticleDto articleDto);


    /**
     * 根据用户id查询用户信息
     * @param userId
     * @return
     */
    @PostMapping("/api/v1/article/queryByUserId/{userId}")
    public ResponseResult queryByUserId(@PathVariable("userId") Integer userId);




    @GetMapping("/api/v1/article/getUserInfo")
    public ResponseResult getUserInfo(@RequestParam Integer authorId);

    /**
     * 获取文章信息
     *
     * @return
     */
    @GetMapping("/api/v1/article/getArticleList")
    public ResponseResult getArticleList(
            @RequestParam(value = "beginDate", required = false) String beginDate,
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam("userId") Integer userId
    );

    @GetMapping("/api/v1/article/getPage")
    public ResponseResult getPage(@RequestParam(value = "beginDate", required = false) String beginDate,
                                  @RequestParam(value = "endDate", required = false) String endDate,
                                  @RequestParam(value = "page", required = false) Integer page,
                                  @RequestParam(value = "size", required = false) Integer size,
                                  @RequestParam("userId") Integer userId);

    /**
     * 修改文章状态
     * @param commentStatus
     * @return
     */
    @PostMapping("/api/v1/article/updateStatus")
    public ResponseResult updateStatus(@RequestBody CommentStatus commentStatus);

    /**
     * 修改文章收藏状态
     * @param behaviorDto
     * @return
     */
    @PostMapping("/api/v1/article/updateCollection")
    ResponseResult updateCollection(@RequestBody CollectionBehaviorDto behaviorDto);


   /* @PostMapping("/api/v1/article/updateCommentCount")
    void updateCommentCount(ApAuthor apAuthor);*/
}
